package com.example.rocket.core;


import lombok.Data;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.client.producer.SendStatus;
import org.springframework.util.StringUtils;

/**
 * @description: MQ发送消息返回结果
 * @author TAO
 * @date 2021/12/24 2:37 下午
 */

@Data
public class NbSendResult {

    private SendStatus sendStatus;

    private String msgId;

    public NbSendResult(SendResult sendResult){
        this.setSendStatus(sendResult.getSendStatus());
        this.setMsgId(sendResult.getMsgId());
    }

    public NbSendResult(com.aliyun.openservices.ons.api.SendResult sendResult){
        this.setSendStatus(StringUtils.isEmpty(sendResult.getMessageId()) ? null : SendStatus.SEND_OK);
        this.setMsgId(sendResult.getMessageId());
    }


}
